package org.example.test.eight;

import com.rabbitmq.client.BuiltinExchangeType;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.DeliverCallback;
import org.example.test.util.RabbitMQUtils;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author: 以默
 * @Date: 2024/7/18 16:26
 *
 * 死信队列
 */
public class Consumer02 {
    // 死信队列的名称
    public static final String DEAD_QUEUE = "dead_queue";


    public static void main(String[] args) throws Exception {
        Channel channel = RabbitMQUtils.getChannel();
        //声明死信和普通交换机
        System.out.println("等待接收消息...");
        DeliverCallback deliverCallback = (consumerTag, message) -> {
            System.out.println("Consumer02接收到消息是：" + new String(message.getBody(), "UTF-8"));
        };
        channel.basicConsume(DEAD_QUEUE, true,deliverCallback,consumerTag -> {});

    }
}
